package com.htu.edu.controller;

import com.htu.edu.bean.Food;
import com.htu.edu.common.R;
import com.htu.edu.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
// 2. 设置该模块的请求路径，如/user
@RequestMapping("/Food")
// 3. 解决跨域
@CrossOrigin
public class FoodController {
    @Autowired
    private FoodService foodService;
    @GetMapping("/listFoodByBusinessId/{businessId}")
    public R listBusinessByOrderTypeId(@PathVariable("businessId") Integer businessId){
        try {
            List<Food> foods = foodService.listFoodByBusinessId(businessId);
            return R.ok().data(foods);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
